|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
J2eeImplWriter.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package org.apache.geronimo.ews.jaxrpcmapping;
|
|
17 |
|
|
18 |
import org.apache.axis.wsdl.symbolTable.BindingEntry;
|
|
19 |
import org.apache.axis.wsdl.symbolTable.Parameter;
|
|
20 |
import org.apache.axis.wsdl.symbolTable.Parameters;
|
|
21 |
import org.apache.axis.wsdl.symbolTable.SymbolTable;
|
|
22 |
import org.apache.axis.wsdl.symbolTable.TypeEntry;
|
|
23 |
import org.apache.axis.wsdl.toJava.JavaClassWriter;
|
|
24 |
import org.apache.axis.wsdl.toJava.Utils;
|
|
25 |
|
|
26 |
import javax.wsdl.Binding;
|
|
27 |
import javax.wsdl.BindingOperation;
|
|
28 |
import javax.wsdl.Operation;
|
|
29 |
import javax.wsdl.OperationType;
|
|
30 |
import javax.xml.rpc.holders.BooleanHolder;
|
|
31 |
import java.io.IOException;
|
|
32 |
import java.io.PrintWriter;
|
|
33 |
import java.util.Iterator;
|
|
34 |
import java.util.List;
|
|
35 |
|
|
36 |
/**
|
|
37 |
* This is Wsdl2java's implementation template writer. It writes the <BindingName>Impl.java
|
|
38 |
* file which contains the <bindingName>Impl class.
|
|
39 |
*
|
|
40 |
* @author Ias (iasandcb@tmax.co.kr)
|
|
41 |
*/
|
|
42 |
public class J2eeImplWriter extends JavaClassWriter { |
|
43 |
protected Binding binding;
|
|
44 |
protected SymbolTable symbolTable;
|
|
45 |
protected BindingEntry bEntry;
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Constructor.
|
|
49 |
*/
|
|
50 | 0 |
protected J2eeImplWriter(J2eeEmitter emitter,
|
51 |
BindingEntry bEntry, |
|
52 |
SymbolTable symbolTable) { |
|
53 | 0 |
super(emitter, bEntry.getName() + "Impl", "templateImpl"); |
54 | 0 |
this.binding = bEntry.getBinding();
|
55 | 0 |
this.symbolTable = symbolTable;
|
56 | 0 |
this.bEntry = bEntry;
|
57 |
} // ctor
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Write the body of the binding's stub file.
|
|
61 |
*/
|
|
62 | 0 |
protected void writeFileBody(PrintWriter pw) throws IOException { |
63 | 0 |
List operations = binding.getBindingOperations(); |
64 | 0 |
for (int i = 0; i < operations.size(); ++i) { |
65 | 0 |
BindingOperation operation = (BindingOperation) operations.get(i); |
66 | 0 |
Operation ptOperation = operation.getOperation(); |
67 | 0 |
OperationType type = ptOperation.getStyle(); |
68 | 0 |
Parameters parameters = |
69 |
bEntry.getParameters(operation.getOperation()); |
|
70 |
|
|
71 |
// These operation types are not supported. The signature
|
|
72 |
// will be a string stating that fact.
|
|
73 | 0 |
if (type == OperationType.NOTIFICATION
|
74 |
|| type == OperationType.SOLICIT_RESPONSE) { |
|
75 | 0 |
pw.println(parameters.signature); |
76 | 0 |
pw.println(); |
77 |
} else {
|
|
78 | 0 |
writeOperation(pw, parameters); |
79 |
} |
|
80 |
} |
|
81 |
} // writeFileBody
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Returns the appropriate implements text
|
|
85 |
*
|
|
86 |
* @return " implements <classes>"
|
|
87 |
*/
|
|
88 | 0 |
protected String getImplementsText() {
|
89 | 0 |
String portTypeName = (String) bEntry.getDynamicVar(J2eeBindingWriter.INTERFACE_NAME); |
90 | 0 |
String implementsText = "implements " + portTypeName;
|
91 | 0 |
return implementsText;
|
92 |
} |
|
93 |
|
|
94 |
/**
|
|
95 |
* Write the implementation template for the given operation.
|
|
96 |
*/
|
|
97 | 0 |
protected void writeOperation(PrintWriter pw, Parameters parms) throws IOException { |
98 | 0 |
pw.println(parms.signature + " {");
|
99 |
|
|
100 |
// Fill in any out parameter holders
|
|
101 | 0 |
Iterator iparam = parms.list.iterator(); |
102 | 0 |
while (iparam.hasNext()) {
|
103 | 0 |
Parameter param = (Parameter) iparam.next(); |
104 | 0 |
if (param.getMode() == Parameter.OUT) {
|
105 |
// write a constructor for each of the parameters
|
|
106 |
|
|
107 | 0 |
BooleanHolder bThrow = new BooleanHolder(false); |
108 | 0 |
String constructorString = |
109 |
Utils.getConstructorForParam(param, symbolTable, bThrow); |
|
110 | 0 |
if (bThrow.value) {
|
111 | 0 |
pw.println(" try {");
|
112 |
} |
|
113 | 0 |
pw.println(" " + Utils.xmlNameToJava(param.getName())
|
114 |
+ ".value = " + constructorString + ";"); |
|
115 | 0 |
if (bThrow.value) {
|
116 | 0 |
pw.println(" } catch (Exception e) {");
|
117 | 0 |
pw.println(" }");
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
// Print the return statement
|
|
123 | 0 |
if (parms.returnParam != null) { |
124 | 0 |
TypeEntry returnType = parms.returnParam.getType(); |
125 | 0 |
pw.print(" return ");
|
126 | 0 |
if (Utils.isPrimitiveType(returnType)) {
|
127 | 0 |
String returnString = returnType.getName(); |
128 | 0 |
if ("boolean".equals(returnString)) { |
129 | 0 |
pw.println("false;");
|
130 | 0 |
} else if ("byte".equals(returnString)) { |
131 | 0 |
pw.println("(byte)-3;");
|
132 | 0 |
} else if ("short".equals(returnString)) { |
133 | 0 |
pw.println("(short)-3;");
|
134 |
} else {
|
|
135 | 0 |
pw.println("-3;");
|
136 |
} |
|
137 |
} else {
|
|
138 | 0 |
pw.println("null;");
|
139 |
} |
|
140 |
} |
|
141 | 0 |
pw.println(" }");
|
142 | 0 |
pw.println(); |
143 |
} // writeOperation
|
|
144 |
|
|
145 |
} |
|
146 |
|
|